<template>
  <div>
    <page-banner></page-banner>
    <page-breadcrumbs :crumbData="crumbData"></page-breadcrumbs>
    <news-list :newsList="newsList"></news-list>
    <page-footer></page-footer>
  </div>
</template>

<script>
import PageBanner from 'components/Banner'
import PageBreadcrumbs from 'components/Breadcrumbs'
import NewsList from './components/List'
import PageFooter from 'components/Footer'
import news from '@/model/news'
export default {
  name: 'News',
  components: {
    PageBanner,
    PageBreadcrumbs,
    NewsList,
    PageFooter
  },
  data () {
    return {
      crumbData: [{
        title: '首页', jump: '/'
      }, {
        title: '新闻中心', jump: '/news'
      }, {
        title: '新闻列表', jump: ''
      }],
      newsList: []
    }
  },
  async created () {
    await this.getNews()
  },
  methods: {
    async getNews () {
      try {
        const page = 1
        const count = 10
        const newsData = await news.getNewsPaging(page, count)
        this.newsList = newsData.items
      } catch (error) {
        if (error.code === 10020) {
          this.newsList = []
        }
      }
    }
  }
}
</script>

<style scoped>

</style>
